package org.styx.storage.rest;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.styx.common.response.R;
import org.styx.common.response.ResultCode;
import org.styx.storage.service.StorageService;

@RestController
@RequestMapping("/storage")
public class StorageController {

    @Autowired
    private StorageService storageService;

    /**
     * 扣减库存
     */
    @RequestMapping("/decrease")
    public R decrease(@RequestParam("productId") Long productId,
                      @RequestParam("count") Integer count) {
        storageService.decrease(productId, count);
        return R.success(ResultCode.SUCCESS,"扣减库存成功！");
    }
}
